var JWTUserSelecter = {
	grid:null,
	show:function(groupid,onSelect){
		var boss = this;
		boss.onSelect = onSelect;
		boss.groupid = groupid;
		boss.dialog = sbl.dialog({
			url:burl+"/JWTTallGroup/addUserDialog.do",
			height:500,
			OnComplete:function(){
				$("#searchBtn").bind("click",function(){
					boss.search();
				});
				$("#submitUserBtn").bind("click",function(){
					boss.onSelect(boss.grid.getSelectRows());
					boss.dialog.remove();
				});
				boss.search();
			}
		});
		sbl.ajax({
			url:burl+"/data/userDept.json",
			success:function(d){
				boss.userDeptdata = d;
				boss.initDeptSelect();
			}
		});
	},
	initDeptSelect:function(){
		var boss = this;
		var pcs = boss.userDeptdata.pcs[1];
		$("#createrpcs").append("<option value=''>-请选择-</option>");
		for(var i =0;i<pcs.length;i++){
			var row = pcs[i];
			var option = $("<option value='"+row.id+"'>"+row.name+"</option>");
			$("#createrpcs").append(option);
		}
		
		$("#createrpcs").bind("change",function(){
			var pcs = $(this).val();
			var sq = boss.userDeptdata.sq[pcs];
			$("#createrjq").empty();
			$("#createrjq").append("<option value=''>-请选择-</option>");
			for(var i =0;i<sq.length;i++){
				var row = sq[i];
				var option = $("<option value='"+row.id+"'>"+row.name+"</option>");
				$("#createrjq").append(option);
			}
		});
	},
	search:function(){
		var boss = this;
		var keyword = $("#keyword").val();
		var data = sbl.getFormData("jwtuserform", false);
		data.groupid = boss.groupid;
		boss.grid = ManagerGrid.grid({
			url: burl + "/JWTTallGroup/getJWTUser.do",
			Data:data,
			columns: [{
				text:"姓名",field: "NAME"
			},{
				text:"单位",field: "DEPARTMENTNAME"
			}],
			OnRender:function(data){
				return data;
			},
			OnComplete:function(){
			}
		}, "userDialogList");
	}
};